<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        //调整窗口大小
        // window.onresize = function(){}
        //响应式布局 window.innerWidth
        var div =document.querySelector('div');
        window.addEventListener('resize',function(){
            console.log('变化了');
            if(window.innerWidth<=800){
                div.style.display = 'none';
            }else{
                div.style.display = 'block';
            }
        })
    </script>
</body>
</html> 